Skip to content

Implementation of LowPass, HighPass, and XCorr Table Functions - #18539

Merged
JackieTien97 merged 5 commits into
apache:masterfrom
alpass163gmail:cyb/table_function_filter_xcorr
Sep 2, 2026
Merged

Implementation of LowPass, HighPass, and XCorr Table Functions#18539
JackieTien97 merged 5 commits into
apache:masterfrom
alpass163gmail:cyb/table_function_filter_xcorr

Conversation

@alpass163gmail

Copy link
Copy Markdown
Contributor

LowPass and HighPass

The LowPass and HighPass functions accept the following parameters:

  • DATA: the input table.
  • TIMECOL: the time column used for ordering. The ORDER BY clause must contain only this time column.
  • WPASS: a double literal in the range (0, 1), which defines the frequency boundary.

For each calculation column, the function collects the complete sequence of finite, non-null values and applies an FFT-based transformation:

  • LowPass keeps the low-frequency components and removes the high-frequency components.
  • HighPass removes the low-frequency components and keeps the high-frequency components.

The inverse FFT is then applied to obtain the transformed sequence. The output contains the partition columns, the original time column, and one DOUBLE result column for each calculation column. Null, NaN, and infinite input values are not included in the FFT calculation.

XCorr

The XCorr function accepts:

  • DATA: the input table.
  • TIMECOL: the time column used for ordering. The ORDER BY clause must contain only this time column.
  • PARTITION BY: optional partition columns.
  • Exactly two calculation columns after excluding the partition columns and the time column.

The two calculation columns are treated as two aligned sequences. The function calculates their cross-correlation for all lags from -(n - 1) to n - 1, where n is the number of rows in the partition.

For each lag, only pairs in which both values are finite and non-null participate in the calculation. The correlation value is normalized by the number of valid pairs for that lag. If a lag has no valid pairs, the corresponding result is returned as null.

The output contains the partition columns and one DOUBLE result column named according to the two calculation columns, for example xcorr(s1, s2). The original time column is used for ordering but is not included in the result.

@JackieTien97 JackieTien97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes because this PR currently fails both the mandatory license check and its newly added integration-test suite, and because XCorr omits the lag key while accepting an input size that makes the synchronous O(n^2) implementation execute 4.29 billion pair iterations. I reproduced the verification failures on head b94bc61: RAT fails on XCorrTableFunction.java; TableSimpleIT and TableClusterIT each run 39 tests with 1 failure. The remaining inline comments cover anonymous fields, floating-point test stability, and i18n compliance.

@JackieTien97
JackieTien97 merged commit 6a236ff into apache:master Sep 2, 2026
38 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants